<extend name="Public/base" />
<block name="main">
    <fieldset class="layui-elem-field">
        <legend>订单管理 - 导出订单</legend>
        <div class="layui-field-box">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red">*</span> 订单批次</label>
                    <div class="layui-inline">
                        <select name="batch">
                            <option value="">选择批次</option>
                            <volist name="batch" id="vo">
                                <option value="{$key}" {:($detail['fid'] == $key?'selected':'')}>{$vo}</option>
                            </volist>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red">*</span> 代理</label>
                    <div class="layui-inline">
                        <select name="agent">
                            <option value="">选择代理</option>
                            <volist name="agent" id="vo">
                                <option value="{$key}" {:($detail['fid'] == $key?'selected':'')}>{$vo}</option>
                            </volist>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"> 统计数据</label>
                    <div class="layui-input-block">
                        <span id="download"></span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="admin-form">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>
</block>
<block name="myScript">
    <script>
        layui.use('form', function(){
            var form = layui.form();
            form.on('submit(admin-form)', function(data){
                //console.log(data.field);
                $.ajax({
                    type: "POST",
                    url: '{:U("count")}',
                    data: data.field,
                    success: function(msg){
                        if( msg.code == 1 ){
                            var str = '普  通: '+ msg.msg.numberP + ' 箱-----利润: '+ msg.msg.lirunP +'元<br/>' +
                                    '精  品: '+ msg.msg.numberJ + ' 箱-----利润: '+ msg.msg.lirunJ +'元<br/>' +
                                    '小  果: '+ msg.msg.numberX + ' 箱-----利润: '+ msg.msg.lirunX +'元<br/>' +
                                    '总利润: ' + msg.msg.lirunZ+'元<br/>' +
                                    '支付果园:' + msg.msg.pay+'元';
                            $('#download').html(str);
                            //parent.location.reload();
                        }else{
                            parent.layer.msg(msg.msg, {
                                icon: 5,
                                shade: [0.6, '#393D49'],
                                time:1500
                            });
                        }
                    }
                });
                return false;
            });
        });
    </script>
</block>